package work20241226;

import java.sql.SQLOutput;

/**
 * @author zdl
 * @date 2024/12/26
 */
public class Demo8 {
    public static void main(String[] args) {
        //8. 创建一个插队线程，让指定线程在当前线程执行完毕后立即执行。
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    System.out.println(Thread.currentThread().getName()+"线程:"+i);

                }
            }
        },"线程1111111111");
        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    System.out.println("线程：" + Thread.currentThread().getName() + ":" + i);
                    if (i == 50){
                        try {
                            t1.join();
                        } catch (InterruptedException e) {
                            throw new RuntimeException(e);
                        }
                    }
                }
            }
        },"线程222222222");
        t1.start();
        t2.start();
    }
}
